tsvImportFromFile
Type
command
Summary
Parse tabular data from a TSV file into an array
Syntax
tsvImportFromFile <pFile>,<pOptions>,<rArray>
Description
This command takes in a filename present in the current defaultFolder, computes the data based on optional parameters and returns it as an array.
The quoting rule determines how quotes are treated in the data to import.
If it is none
then quotes have no effect on parsing,
and the data is just split based on the chosen delimiter.
Otherwise quoted values can contain the delimiter itself
as well as return characters.
When specifying the quoting-rule for TSV import, consider the following options:
- "all": All fields are quoted
- "minimal": Fields with special characters (like delimiter) have quotes
- "none": Quotes have no effect on parsing
Parameters
Name | Type | Description |
---|---|---|
pFile | File Name | |
pOptions | An array of options to use when importing tsv. The keys are as follows:
| |
rArray | Returns a nested array with data parsed from input file with format: { "headers": [ col1header, col2header,...], "data": [ [row1col1data, row1col2data, ...], [row2col1data, row2col2data, ...] ] } |
Examples
local tFile
answer file "Select a tsv file" with type "TSV files|tsv|TSV"
put the result into tFile
local tArray
tsvImportFromFile \
tFile, \
{ "has-header-row": true }, \
tArray